{% extends "base.html" %}
{% load i18n %}
{% block javascript %}
{{ block.super }}
<link type="text/css" rel="stylesheet" href="{{ STATIC_URL }}css/openid-shadow.css" />

<script type="text/javascript" src="{{ STATIC_URL }}js/openid-jquery.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}js/openid-en.js"></script>

<script type="text/javascript">
	$(document).ready(function() {
		openid.init('openid_identifier');
		//openid.setDemoMode(false); //Stops form submission for client javascript-only test purposes
	});
</script>

{% comment %}	
<script type="text/javascript">
var openid_suggestions = [
{% for s in openid_suggestions %}
"{{ s.1 }}",
{% endfor %}
];

function changeProvider() {
    select = document.getElementById("id_openid_identifier");
    username_block = document.getElementById("username_block");
    index = select.selectedIndex;
    if (openid_suggestions[index] == "") { // assume no username required
        username_block.style.display = "none";
    }
    else {
        document.getElementById("suggestion").innerHTML = openid_suggestions[index];
        username_block.style.display = "block";
    }
}
/*window.onload = function() {
    document.getElementById("id_openid_identifier").onchange = changeProvider;
    changeProvider();
}*/
</script>
{% endcomment %}
{% endblock %}

{% block title %}
Sign In
{% endblock %}

{% block content %}


<!-- Simple OpenID Selector -->
<form action="" method="post" id="openid_form">
    {% csrf_token %}
	<input type="hidden" name="action" value="verify" />
	<div id="openid_errors">
	{% if openid_error %}
	    <ul class="errorlist"><li>{{ openid_error }}</li></ul>
	{% endif %}
	</div>
	<div id="openid_choice">
		<p>Please select an OpenID provider to use.</p>
		<div id="openid_btns"></div>
	</div>
	<div id="openid_input_area">
		<input id="openid_identifier" name="openid_identifier" type="text" value="http://" />
		<input id="openid_submit" type="submit" value="Sign in"/>
	</div>
	<noscript>
		<p>OpenID is service that allows you to log-on to many different websites using a single indentity.
		Find out <a href="http://openid.net/what/">more about OpenID</a> and <a href="http://openid.net/get/">how to get an OpenID enabled account</a>.</p>
	</noscript>
</form>
<!-- /Simple OpenID Selector -->
{% comment %}
{% if form.errors %}
<p class="errors">{% trans "Please correct errors below:" %}<br />
    {% if form.openid_identifier.errors %}
    <span class="error">{{ form.openid_identifier.errors|join:", " }}</span>
    {% endif %}
    {% if form.next.errors %}
    <span class="error">{{ form.next.errors|join:", " }}</span>
    {% endif %}
</p>
{% endif %}
<form name="fopenid" action="{{ action }}" method="post">
    {% csrf_token %}
    <fieldset>
        <legend>{% trans "Sign In Using Your OpenID" %}</legend>
        <div class="form-row">
            <label for="id_openid_identifier">{% trans "OpenID Provider:" %}</label><br />
            {{ form.openid_identifier }}
        </div>
        <div class="form-row" id="username_block">
            <label for="id_openid_identifier">{% trans "Username:" %}</label><br />
            {{ form.username }}
            <span id="suggestion"></span>
        </div>
        <br />
        <div class="submit-row ">
            <input name="bsignin" type="submit" value="{% trans "Sign in" %}">
        </div>
 {% if next %}
        <input type="hidden" name="next" value="{{ next }}" />
 {% endif %}
    </fieldset>
</form>
{% endcomment %}
{% endblock %}
